package service.subject;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.common.BaseMapper;
import com.common.BaseService;

import beans.subject.subinfo;
import beans.wxresult.Rec;
import mapper.subject.subinfoMapper;

@Service
@Transactional
public class SubInfoServiceImpl<T> extends BaseService<T>{

	@Autowired
	private subinfoMapper<T> _subinfoMapper;

	@Override
	public BaseMapper<T> getMapper() {
		return _subinfoMapper;
	}

	/**
	 * 更新章节表和题型表的题目数量
	 * @param chapterid
	 * @param specialid
	 */
	public void updateChapterSpecial(String chapterid, String specialid) {
		_subinfoMapper.updateChapterSpecial(chapterid,specialid);
	}

	public List<subinfo> getByIds(String[] ids) {
		return _subinfoMapper.getByIds(ids);
	}
	
	/**
	 * 同时减掉章节表和提醒表数量
	 * @param ids
	 * @param temSql
	 */
	public void deletes(String[] ids, String temSql) {
		_subinfoMapper.deletes(ids,temSql);
	}

	/**
	 * 根据类型和科目获取题目
	 * @param drivertype
	 * @param subtype
	 * @return
	 */
	public List<subinfo> getByDriverAndSpecial(String drivertype, String subtype) {
		return _subinfoMapper.getByDriverAndSpecial(drivertype,subtype);
	}

	public List<T> getSubjectInfo(String type) {
		if(type.equals("free"))
			return _subinfoMapper.getSubjectInfo();
		else 
			return _subinfoMapper.getSubjectInfo2(type);
	}

	/**
	 * 根据章节id获取题目
	 * @param id
	 * @return
	 */
	public List<T> getZhangjieSubject(String id) {
		return _subinfoMapper.getZhangjieSubject(id);
	}

	/**
	 * 顺序训练
	 * @param id
	 * @return
	 */
	public List<subinfo> getShunXuSubject(String exam,String examtype) {
		return _subinfoMapper.getByDriverAndSpecial(exam, examtype);
	}

	public List<T> getZhuanXiang(String id) {
		return _subinfoMapper.getZhuanXiang(id);
	}

	public List<T> getAll() {
		return null;
	}

	/**
	 * 我的错题
	 * @param exam
	 * @param examtype
	 * @param id
	 * @return
	 */
	public List<T> getErrorSubinfo(String exam, String examtype, String uid) {
		return _subinfoMapper.getErrorSubinfo(exam,examtype,uid);
	}

	public void adds(List<T> mapList) {
		_subinfoMapper.adds(mapList);
	}

	/**
	 * 批量更新专题id
	 * @param ids
	 */
	public void updateSecial(List<String> ids,String specialid) {
		_subinfoMapper.updateSecial(ids,specialid);
	}
}